<style lang="less">
  .order-modify-sty {
    /*.el-row {*/
    /*margin-bottom: 20px;*/
    /*}*/

    .el-col {
      border-radius: 4px;
    }

    .bg-purple-dark {
      background: #ffffff;
    }

    .grid-content {
      border-radius: 4px;
      min-height: 36px;
    }

    .el-form-item {
      margin: 0px 20px 15px 20px;
    }

    .f-bs1 {
      border: 1px solid #dfe6ec;
    }

    .el-collapse {
      border: 0px;
      .el-collapse-item {
        border: 1px solid #dfe6ec;
        margin-bottom: 10px;
        .el-collapse-item__header {
          font-weight: bold;
          .el-collapse-item__header__arrow {
            display: none;
          }
        }
        .el-collapse-item__content {
          padding-bottom: 0px;
        }
        .el-collapse-item__wrap {
          border-bottom: 0px;
          .el-collapse-item__content {
            padding: 0px 0px;
          }
        }
      }
      .ecl-um-sy {
        .el-collapse-item__wrap {
          height: 48px;
        }
      }
      .eci-time-sty {
        .el-collapse-item__wrap {
          height: 100px;
          .el-collapse-item__content {
            height: 100px;
          }
        }
      }
    }

    label {
      width: 100px;
    }

    .el-form-item[data-v-7da61f17] {
      margin: 0 0 0 0
    }

    .f-mt10 {
      margin-top: 10px;
    }

    .f-ml20 {
      margin-left: 20px;
    }

    .f-mr20 {
      margin-right: 20px;
    }

    .f-mb10 {
      margin-bottom: 10px;
    }

    .f-tar {
      text-align: right;
    }

    .f-h30 {
      height: 30px;
    }

    .f-c-red {
      color: red;
    }

    .el-radio-group {
      width: 60%;
    }

    .el-radio-invoice {
      margin-right: 30px;
    }

    .f-color {
      color: #25baaf;
    }

    .el-textarea {
      width: 86%;
    }

    .f-mb {
      margin-bottom: 0;
    }

    .f-fr {
      float: right;
    }

    .f-fl {
      float: left;
    }

    .f-lh38 {
      line-height: 38px;
    }

    .el-select {
      width: 100%;
    }

    .f-w233 {
      width: 100%;
    }
    .f-w130 {
      width: 135%;
    }
    .el-form-item__label {
      width: 150px;
    }

    .el-date-editor.el-input {
      width: 100%;
    }

    li {
      list-style-type: none;
    }

    .color-c8c8c8 {
      color: #c8c8c8;
    }

    .f-mt {
      margin-top: 0;
    }
    .el-collapse-item__header {
      height: 40px;
      line-height: 40px;
    }

    .el-form-item {
      margin: 0px 0px 15px 20px;
    }
    .el-col-4 {
      width: 18%;
    }
    .efi-cargo-sty {
      .el-form-item__content {
        line-height: 0px;
        margin-top: 3px;
      }
    }
    .el-input {
      height: 22px;
    }
    .el-input .el-input__inner {
      height: 22px;
    }
    .el-input__icon {
      margin-top: 7px;
    }
    .el-form-item__error {
      /*padding-top: 23px;*/
      top: 17px;
    }
    .f-bs1 {
      border: 1px solid #dfe6ec;
    }

    .f-bsr1 {
      border-right: 1px solid #dfe6ec;
      border-radius: 0;
    }

    .f-bl1 {
      border-left: 1px solid #dfe6ec;
    }

    .f-bsb1 {
      border-bottom: 1px solid #dfe6ec;
      border-right: 1px solid #dfe6ec;
      border-left: 1px solid #dfe6ec;
    }

    .f-bcc {
      background-color: #bedbf7;
    }

    .f-tc {
      text-align: center;
      color: black;
    }
  }
</style>

<template>
  <div class="order-modify-sty">
    <el-row style="margin-bottom: 0">
      <el-col :span="24">
        <el-button type="text" @click="backClick">返回上一页</el-button>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div class="f-bs1 grid-content bg-purple-dark">
          <div class="f-fl f-lh38 f-ml20">
            订单编号：
            <label>{{orderForm.orderNumber}}&nbsp;&nbsp;</label>
            <label v-if="orderForm.orderSource === 101004001"
                   style="color: #075eee;">[Android下单]</label>
            <label v-if="orderForm.orderSource === 101004002" style="color: #075eee;">[IOS下单]</label>
            <label v-if="orderForm.orderSource === 101004003" style="color: #075eee;">[微信下单]</label>
            <label v-if="orderForm.orderSource === 101004004" style="color: #075eee;">[PC下单]</label>
            <label v-if="orderForm.orderSource === 101004005" style="color: #075eee;">[接口下单]</label>
            <label style="color: #075eee;">[{{orderForm.orderStatusName}}]</label>
            <label style="color: #075eee;">[{{orderForm.payStatusName}}]</label>
          </div>
          <div class="f-fr f-lh38 f-mr20">
            <label style="color: #075eee;" v-if="orderForm.createUserName != null">[{{orderForm.createUserName}}]&nbsp;&nbsp;</label>
            <label style="color: #075eee;">[{{orderForm.organizationName}}]&nbsp;&nbsp;</label>
            <label>{{orderForm.createDate}}&nbsp;&nbsp;</label>
          </div>
        </div>
      </el-col>
    </el-row>
    <el-form ref="orderForm" label-position="right" label-width="110px" :model="orderForm" :rules="rules">
      <el-collapse v-model="activeNames">
        <el-collapse-item title="客户" name="1" class="ecl-um-sy">
          <el-row class="f-mt10 f-mb10">
            <el-col :span="4">
              <el-form-item label="客户名称">
                <el-input :disabled="true" v-model="orderForm.memberUserName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="货运单号" prop="freightNumber">
                <el-input v-model="orderForm.freightNumber"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="运单号" prop="transportationNumber">
                <el-input v-model="orderForm.transportationNumber" placeholder="请输入运单号"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="发货地址" name="3" class="ecl-um-sy">
          <el-row>
            <el-col :span="4">
              <el-form-item label="发货人" prop="shipmentsContactName">
                <el-input v-if="orderStatus.agingDictEntityId===112006003&&orderStatus.djagingDictEntityPayNoAss"
                          v-model="orderForm.shipmentsContactName"></el-input>
                <el-select v-if="orderStatus.agingDictEntityId===112006003&&!orderStatus.djagingDictEntityPayNoAss"
                           v-model="orderForm.shipmentsContactName"
                           @visible-change="searchShipmentAddresses(109002002)"
                           filterable clearable placeholder="请选择发货人"
                           @change="shipmentsContactNameChange">
                  <el-option v-for="shipmentAddress in shipmentAddresses"
                             :label="shipmentAddress.contactName"
                             :key="shipmentAddress.id"
                             :value="shipmentAddress.id"></el-option>
                </el-select>
                <el-input v-if="orderStatus.agingDictEntityId!==112006003&&!orderStatus.swartnotAss"
                          v-model="orderForm.shipmentsContactName"></el-input>
                <el-select v-if="orderStatus.agingDictEntityId!==112006003&&orderStatus.swartnotAss"
                           v-model="orderForm.shipmentsContactName"
                           @visible-change="searchShipmentAddresses(109002002)"
                           :disabled="orderStatus.awaitPayAndAlreadyAssign||orderStatus.alreadyPay"
                           filterable clearable placeholder="请选择发货人"
                           @change="shipmentsContactNameChange">
                  <el-option v-for="shipmentAddress in shipmentAddresses"
                             :label="shipmentAddress.contactName"
                             :key="shipmentAddress.id"
                             :value="shipmentAddress.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="手机号码" prop="shipmentsContactPhone">
                <el-input type="number" v-model="orderForm.shipmentsContactPhone"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="固定电话" prop="shipmentTelephone">
                <el-input type="number" v-model="orderForm.shipmentsTelephone"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="所在地" prop="shipmentAddressesSelect">
                <address-select v-if="orderStatus.agingDictEntityId===112006003"
                                :disabled="orderStatus.djagingDictEntityPayNoAss"
                                v-model="orderForm.shipmentAddressesSelect"
                                @change="addressSelectChange('shipmentAddress')"
                                placeholder="请选择地址"
                                class="f-w130"></address-select>
                <address-select v-if="orderStatus.agingDictEntityId!==112006003"
                                v-model="orderForm.shipmentAddressesSelect"
                                :disabled="orderStatus.awaitPayAndAlreadyAssign||orderStatus.alreadyPay"
                                @change="addressSelectChange('shipmentAddress')"
                                placeholder="请选择地址"
                                class="f-w130"></address-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="详细地址" prop="shipmentsStreet">
                <el-input class="f-w130" v-model="orderForm.shipmentsStreet"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="收货地址" name="4" class="ecl-um-sy">
          <el-row>
            <el-col :span="4">
              <el-form-item label="收货人" prop="sendContactName">
                <el-input v-if="orderStatus.agingDictEntityId===112006003&&orderStatus.djagingDictEntityPayNoAss"
                          v-model="orderForm.sendContactName"></el-input>
                <el-select v-if="orderStatus.agingDictEntityId===112006003&&!orderStatus.djagingDictEntityPayNoAss"
                           v-model="orderForm.sendContactName"
                           @visible-change="searchShipmentAddresses(109002001)"
                           filterable clearable placeholder="请选择收货人"
                           @change="sendContactNameChange">
                  <el-option v-for="sendAddress in sendAddresses"
                             :label="sendAddress.contactName"
                             :key="sendAddress.id"
                             :value="sendAddress.id"></el-option>
                </el-select>
                <el-input v-if="orderStatus.agingDictEntityId!==112006003&&!orderStatus.swartnotAss"
                          v-model="orderForm.sendContactName"></el-input>
                <el-select v-if="orderStatus.agingDictEntityId!==112006003&&orderStatus.swartnotAss"
                           v-model="orderForm.sendContactName"
                           :disabled="orderStatus.awaitPayAndAlreadyAssign||orderStatus.alreadyPay"
                           @visible-change="searchShipmentAddresses(109002001)"
                           filterable clearable placeholder="请选择收货人"
                           @change="sendContactNameChange">
                  <el-option v-for="sendAddress in sendAddresses"
                             :label="sendAddress.contactName"
                             :key="sendAddress.id"
                             :value="sendAddress.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="手机号码" prop="sendContactPhone">
                <el-input type="number" v-model="orderForm.sendContactPhone"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="固定电话" prop="sendTelephone">
                <el-input type="number" v-model="orderForm.sendTelephone"
                          placeholder="请输入固定电话"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="所在地" prop="sendAddressSelect">
                <address-select v-model="orderForm.sendAddressSelect"
                                :disabled="orderStatus.djagingDictEntityPayNoAss"
                                v-if="orderStatus.agingDictEntityId===112006003"
                                @change="addressSelectChange('sendAddress')" placeholder="请选择地址"
                                class="f-w130"></address-select>
                <address-select v-model="orderForm.sendAddressSelect"
                                v-if="orderStatus.agingDictEntityId!==112006003"
                                :disabled="orderStatus.awaitPayAndAlreadyAssign||orderStatus.alreadyPay"
                                @change="addressSelectChange('sendAddress')" placeholder="请选择地址"
                                class="f-w130"></address-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="详细地址" prop="sendStreet">
                <el-input class="f-w130" v-model="orderForm.sendStreet"
                          placeholder="请输入详细地址"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="计划时间" name="2">
          <el-row style="margin-bottom: 0px">
            <el-col :span="4">
              <el-form-item class="f-mb" label="发货日期" prop="shipmentsDate">
                <div class="block f-h30">
                  <ue-el-date-picker v-if="orderStatus.agingDictEntityId===112006003" v-model="orderForm.shipmentsDate"
                                     @change="calculatePrice"
                                     :picker-options="shipmentsDateValuePOS"></ue-el-date-picker>
                  <ue-el-date-picker v-if="orderStatus.agingDictEntityId!==112006003" :disabled="orderStatus.alreadyPay"
                                     v-model="orderForm.shipmentsDate"
                                     @change="calculatePrice"
                                     :picker-options="shipmentsDateValuePOS"></ue-el-date-picker>
                  <!--<div style="float: left">-->
                  <!--<label style="float: left;width: auto">提前发运享受优惠: </label>-->
                  <label class="f-c-red" style="float: left;width: 30px;display: none"
                         v-html="discountText"></label>
                  <!--</div>-->
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="提货方式" prop="extractType">
                <el-select :disabled="orderStatus.awaitPayAndAlreadyAssign||orderStatus.alreadyPay"
                           v-model="orderForm.extractType"
                           @change="searchextractTypeChange"
                           filterable placeholder="请选择提货方式">
                  <el-option v-for="et in extractTypes" :label="et.cnDictValname" :key="et.dictVal"
                             :value="et.dictVal"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="提货网点" v-if="orderForm.extractType===105002002" prop="startNetworkManagementId">
                <el-select v-model="orderForm.startNetworkManagementId"
                           filterable
                           placeholder="请选择提货网点">
                  <el-option v-for="(enm,index) in startNetworkManagements" :key="index" :label="enm.netWorkName"
                             :value="enm.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item class="f-mb" label="计划提货日期" prop="extractDate" v-if="orderForm.extractType===105002001"
                            :rules="[ {required: true,type:'date', message: '请选择计划提货日期', trigger: 'blur'}]">
                <div class="block f-h30">
                  <el-date-picker format="yyyy-MM-dd"
                                  :disabled="orderStatus.alreadyPay"
                                  v-model="orderForm.extractDate" type="date" placeholder="选择计划提货日期"
                                  :picker-options="extractTimeValuePOS"></el-date-picker>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="计划提货时间" prop="extractTime" v-if="orderForm.extractType===105002001"
                            :rules="[ {required: true, message: '请选择计划提货时间', trigger: 'blur'}]">
                <el-select
                  :disabled="orderStatus.alreadyPay"
                  v-model="orderForm.extractTime"
                  filterable placeholder="请选择计划提货时间">
                  <el-option v-for="extractTime in extractTimes" :label="extractTime.cnDictValname"
                             :key="extractTime.dictVal"
                             :value="extractTime.dictVal"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row style="margin-bottom: 0px">
            <el-col :span="4">
              <el-form-item label="">
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="送货方式" prop="sendType">
                <el-select v-if="orderStatus.agingDictEntityId===112006003" v-model="orderForm.sendType"
                           filterable
                           @change="sendTypeTypeChange"
                           placeholder="请选择送货方式">
                  <el-option v-for="sendType in sendTypes" :label="sendType.cnDictValname"
                             :key="sendType.dictVal"
                             :value="sendType.dictVal"></el-option>
                </el-select>
                <el-select v-if="orderStatus.agingDictEntityId!==112006003" :disabled="orderStatus.alreadyPay"
                           v-model="orderForm.sendType"
                           filterable
                           @change="sendTypeTypeChange"
                           placeholder="请选择送货方式">
                  <el-option v-for="sendType in sendTypes" :label="sendType.cnDictValname"
                             :key="sendType.dictVal"
                             :value="sendType.dictVal"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="送货网点" v-if="orderForm.sendType===105001002" prop="endNetworkManagementId">
                <el-select v-model="orderForm.endNetworkManagementId"
                           filterable
                           placeholder="请选择送货网点">
                  <el-option v-for="(snm,index) in endNetworkManagements" :key="index" :label="snm.netWorkName"
                             :value="snm.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item style="margin-bottom: 0px" label="计划送货时间" prop="sendTime"
                            v-if="orderForm.sendType===105001001">
                <div class="block f-h30">
                  <el-date-picker
                    v-model="orderForm.sendTime" type="date" placeholder="选择计划送货时间"
                    :picker-options="sendTimeValuePOS"></el-date-picker>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-form ref="orderCargoForm" label-position="right" label-width="100px" :model="orderCargoForm"
                 :rules="orderCargoFormRules">
          <el-collapse v-model="activeNames">
            <el-collapse-item title="货物信息" name="5">
              <el-row>
                <el-col :span="4">
                  <el-form-item label="货物品名" prop="cargoId">
                    <el-select v-if="!isCargoShow" v-model="orderCargoForm.cargoId"
                               filterable
                               :disabled="orderStatus.alreadyPayCon"
                               placeholder="请选择货物品名" @change="cargoNameChanges">
                      <el-option v-for="cargoModel in cargoNames" :label="cargoModel.name"
                                 :key="cargoModel.id"
                                 :value="cargoModel.id"></el-option>
                    </el-select>
                    <el-input v-if="isCargoShow" v-model="orderCargoForm.cargoName"
                              placeholder="请输入货物品名"></el-input>
                    <el-button type="text" class="f-fr" style="position: relative;padding: 0px 0px"
                               @click="elseCargoClick">{{isCargoShowText}}
                    </el-button>
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item label="货物类型" prop="cargoTypeName">
                    <el-input :disabled="true" v-model="orderCargoForm.cargoTypeName"
                              placeholder="货物类型"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item label="货物包装" prop="packType">
                    <el-select v-if="!isPackTypeShow" v-model="orderCargoForm.packType" @change="packTypeChanges"
                               filterable placeholder="请选择货物包装">
                      <el-option v-for="packType in packTypes" :label="packType.cnDictValname"
                                 :key="packType.dictVal"
                                 :value="packType.dictVal"></el-option>
                    </el-select>
                    <el-input v-if="isPackTypeShow" v-model="orderCargoForm.packTypeName"
                              placeholder="请输入货物包装"></el-input>
                    <el-button type="text" class="f-fr" style="position: relative;padding: 0px 0px"
                               @click="elsePackTypeClick">{{isPackTypeShowText}}
                    </el-button>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="货物备注" prop="remark">
                    <el-input style="height: 30px;" type="textarea" v-model="orderCargoForm.remark"
                              placeholder="请输入货物备注"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="4">
                  <el-form-item label="重量（吨）" prop="weight">
                    <el-input v-if="orderStatus.agingDictEntityId===112006003" type="number" step="0.01"
                              v-model.number="orderCargoForm.weight"
                              @blur="changeVolumeAndWeight"
                              placeholder="请输入重量"></el-input>
                    <el-input v-if="orderStatus.agingDictEntityId!==112006003" :disabled="orderStatus.alreadyPay"
                              type="number" step="0.01"
                              v-model.number="orderCargoForm.weight"
                              @blur="changeVolumeAndWeight"
                              placeholder="请输入重量"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item label="体积（方）" prop="volume">
                    <el-input v-if="orderStatus.agingDictEntityId===112006003" type="number" step="0.01"
                              v-model.number="orderCargoForm.volume"
                              @blur="changeVolumeAndWeight"
                              placeholder="请输入体积"></el-input>
                    <el-input v-if="orderStatus.agingDictEntityId!==112006003" :disabled="orderStatus.alreadyPay"
                              type="number" step="0.01"
                              v-model.number="orderCargoForm.volume"
                              @blur="changeVolumeAndWeight"
                              placeholder="请输入体积"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="4">
                  <el-form-item label="件数" prop="amount">
                    <el-input v-if="orderStatus.agingDictEntityId===112006003" type="number"
                              v-model.number="orderCargoForm.amount"
                              placeholder="请输入件数"></el-input>
                    <el-input v-if="orderStatus.agingDictEntityId!==112006003" :disabled="orderStatus.alreadyPay"
                              type="number" v-model.number="orderCargoForm.amount"
                              placeholder="请输入件数"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row v-if="isHeavyRatioInterval||iszp">
                <el-col :span="15">
                  <el-form-item label="重泡比提示">
                    <el-input :disabled="true" v-model="mStmHeavyRatioInterval.promptCopy"
                              placeholder="请输入件数"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-collapse-item>
          </el-collapse>
        </el-form>
        <el-collapse-item title="服务" name="6" class="ecl-um-sy">
          <template slot="title" class="ecl-um-sy">
            <div>
              <el-col :span="1">增值服务</el-col>
              <el-col :span="2">
                <el-form-item label="等通知放货" label-width="100px" style="margin-bottom: 0px">
                  <el-checkbox style="width: auto" v-model="noticeDelivery"></el-checkbox>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-tooltip placement="top">
                  <div slot="content">发货人委托平台把货物发送到目的地，货物到达目的地之后，平台必须先收到发货人的通知，方可将货物移交(送达)给收货人。
                    发货人需在3天内确认放货，若超过3天未通知放货，平台将按货量和天数，收取一定的仓储费。
                  </div>
                  <el-button type="text"><i class="f-color fa fa-info-circle" aria-hidden="true"></i></el-button>
                </el-tooltip>
              </el-col>
            </div>
          </template>
          <el-row>
            <el-col :span="4">
              <el-form-item label="保价声明" prop="">
                <el-input :disabled="orderStatus.alreadyPay" type="number" v-model.number="addValues[0].value"
                          placeholder="请输入保价声明"
                          @blur="addValueChange('bj')">
                  <template slot="append">
                    <el-tooltip placement="top">
                      <div slot="content">保价声明金额不低于3千，不高于100万保险费率0.02%</div>
                      <el-button type="text"><i class="f-color fa fa-info-circle" aria-hidden="true"></i>
                      </el-button>
                    </el-tooltip>
                  </template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="代收金额">
                <el-input :disabled="orderStatus.alreadyPay" type="number" v-model.number="addValues[1].value"
                          placeholder="请输入代收金额"
                          @blur="addValueChange('ds')">
                  <template slot="append">
                    <el-tooltip placement="top">
                      <div slot="content">贷款金额大于0且不高于5万代收货款率0.3%</div>
                      <el-button type="text"><i class="f-color fa fa-info-circle" aria-hidden="true"></i></el-button>
                    </el-tooltip>
                  </template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="回单类型" prop="receiptType">
                <el-select :disabled="hdds||orderStatus.alreadyPay" v-model="addValues[2].value"
                           clearable
                           @change="searchReceiptTypeChange"
                           placeholder="请选择回单类型">
                  <el-option v-for="receiptType in receiptTypes" :label="receiptType.cnDictValname"
                             :key="receiptType.dictVal"
                             :value="receiptType.dictVal"></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="4">
              <el-form-item label="发票类型" prop="invoiceType">
                <el-select :disabled="inds||orderStatus.alreadyPay"
                           v-model="addValues[3].dictValue"
                           clearable
                           @change="invoiceTypeChange"
                           placeholder="请选择发票类型">
                  <el-option v-for="invoiceType in invoiceTypes"
                             :label="invoiceType.cnDictValname"
                             :key="invoiceType.dictVal"
                             :value="invoiceType.dictVal"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item label="发票抬头">
                <el-input v-if="orderForm.agingDictEntityId === 112006004"
                          :disabled="fbtitleds||orderStatus.alreadyPay"
                          v-model="orderForm.valueMessage"
                          placeholder="请输入发票抬头"></el-input>
                <el-select v-if="orderForm.agingDictEntityId !== 112006004"
                           :disabled="orderStatus.alreadyPay"
                           v-model="taxsheetTitle"
                           @change="searchTaxsheetTitleChange"
                           placeholder="请选择发票抬头">
                  <el-option v-for="tht in taxsheetTitles" :label="tht.taxsheetTitle"
                             :key="tht.id"
                             :value="tht.id">
                    <template slot="append">
                      <el-tooltip placement="top">
                        <div slot="content">普通发票税率 3%</div>
                        <el-button type="text"><i class="f-color fa fa-info-circle" aria-hidden="true"></i>
                          发 &nbsp; &nbsp; 票
                        </el-button>
                      </el-tooltip>
                    </template>
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="运输产品" name="8" property="agingId">
          <el-row class="f-ml10 f-mb10">
            <el-radio-group v-model="orderForm.agingModel" prop="agingId" :disabled="orderStatus.alreadyPay"
                            @change="bfcalculatePrice">
              <div v-for="shipping in shippings" :key="shipping.ageingType" class="f-mt10">
                <el-radio class="radio" :label="shipping">
                  {{shipping.ageingTypeName}}
                  <label v-if="shipping.ageingType!==112006003" class="f-ml20">{{shipping.remark}}</label>
                  <label v-if="shipping.ageingType!==112006003&&shipping.ageingType!==112006004"
                         class="f-ml20 f-color">预计{{shipping.ageingScope}}到达，起步运费{{shipping.startToll}}，重货{{shipping.heavy}}元/吨</label>
                  <label v-if="shipping.ageingType===112006003" class="f-ml20">
                    <el-input type="number"
                              :disabled="orderStatus.alreadyPay"
                              v-if="orderForm.agingDictEntityId === 112006003" v-model="freightPrice"
                              @change="pricing" style="margin-left: 20px;width: 150px"
                              placeholder="请输入价格"></el-input>
                    <el-input type="number"
                              :disabled="orderStatus.alreadyPay"
                              v-if="orderForm.agingDictEntityId === 112006003" v-model="freightMsgPrice"
                              @change="pricing"
                              style="margin-left: 20px;width: 150px"
                              placeholder="请输入信息服务"></el-input>
                  </label>
                </el-radio>
              </div>
            </el-radio-group>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="付款方式" name="7">
          <el-row class="f-ml10 f-mb10">
            <el-radio-group v-model="orderForm.paymentType" @change="calculatePrice">
              <el-radio v-for="(py,index) in paymentTypes" class="radio" :label="py.payWay" :key="index">
                {{py.payWayName}}
              </el-radio>
            </el-radio-group>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="订单备注" name="9">
          <el-row style="margin-top: 3px">
            <el-col :span="10">
              <el-form-item label="订单备注" prop="remark">
                <el-input type="textarea" v-model="orderForm.remark"
                          placeholder="请输入订单备注"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="费用详情" name="10">
          <el-row style="width: 100%;margin: auto" class="f-bs1">
            <el-col :span="6" class="f-bsr1 f-tc f-bcc">
              <div class="grid-content">短途提货费
                <label class="grid-content f-text-red f-fr" v-html="duthf"></label>
              </div>
            </el-col>
            <el-col :span="6" class="f-bsr1 f-tc f-bl1 f-bcc">
              <div class="grid-content">保价运费
                <label class="grid-content f-text-red f-fr" v-html="bjyf"></label>
              </div>
            </el-col>
            <el-col :span="6" class="f-bsr1 f-tc f-bcc">
              <div class="grid-content">干线运费
                <label class="f-text-red f-fr" style="width: auto" v-html="gxyf">
                </label>
              </div>
            </el-col>
            <el-col :span="6" class="f-bsr1 f-tc f-bl1 f-bcc">
              <div class="grid-content">代收货款费
                <label class="grid-content f-text-red f-fr" v-html="dshkf"></label>
              </div>
            </el-col>
          </el-row>
          <el-row style="width: 100%;margin: auto" class="f-bsb1">
            <el-col :span="6" class="f-bsr1 f-tc f-bcc">
              <div class="grid-content">短途送货费
                <label class="grid-content f-text-red f-fr" v-html="dtshf"></label>
              </div>
            </el-col>
            <el-col :span="6" class="f-bsr1 f-tc f-bcc" v-if="orderForm.agingDictEntityId===112006003">
              <div class="grid-content">信息费
                <label v-if="orderForm.agingDictEntityId===112006003" class="grid-content f-text-red f-fr"
                       v-html="xxf"></label>
              </div>
            </el-col>
            <el-col :span="6" class="f-bsr1 f-tc f-bcc" v-if="orderForm.agingDictEntityId!==112006003">
              <!--<div class="grid-content">月结费-->
              <!--<label v-if="orderForm.agingDictEntityId!==112006003" class="grid-content f-text-red f-fr"-->
              <!--v-html="yjf"></label>-->
              <!--</div>-->
            </el-col>
            <el-col :span="6" class="f-bsr1 f-tc f-bl1 f-bcc">
              <div class="grid-content">回单费
                <label class="grid-content f-text-red f-fr" v-html="hdf"></label>
              </div>
            </el-col>
            <el-col :span="6" class="f-bsr1 f-tc f-bl1 f-bcc">
              <div class="grid-content">发票费
                <label class="grid-content f-text-red f-fr" v-html="fpf"></label>
              </div>
            </el-col>
          </el-row>
        </el-collapse-item>
      </el-collapse>
      <div class="f-tar f-mt10 f-mb10">
        <div class="f-tar f-mt10 f-mb10">
          <el-button type="primary" style="width: auto;" @click="calculatePrice">预估费用</el-button>
        </div>
        <li class="f-mt10"><label v-html="totalPrice"></label>
        </li>
      </div>
      <div class="f-tar f-mt10 f-mb10">
        <el-button type="primary" style="width: auto;" @click="createOrder(101001001,'save')">保存</el-button>
      </div>
    </el-form>
    <el-collapse>
      <el-collapse-item title="修改记录">
        <el-row>
          <el-table
            :data="orderRecord"
            border
            style="width: 100%">
            <el-table-column
              prop="propertyName"
              label="修改项"
              width="180">
            </el-table-column>
            <el-table-column
              prop="oldValueName"
              label="修改前"
              width="180">
            </el-table-column>
            <el-table-column
              prop="newValueName"
              label="修改后">
            </el-table-column>
            <el-table-column
              prop="createDate"
              label="修改时间">
            </el-table-column>
            <el-table-column
              prop="createUserName"
              label="修改人">
            </el-table-column>
          </el-table>
        </el-row>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
import { getStmParamByType } from '../../api/system/stmParam.js';
import { getMemberUsers } from '../../api/customer/maintain.js';
import { getFreightAddValue, searchReservationRuleFreights } from '../../api/freight/freightApi.js';
import { getDictEntityByDictCode, getDictEntity } from '../../api/system/Dict.js';
import { getItemNames } from '../../api/system/ItemName.js';
import { getAddresses } from '../../api/address/address.js';
import { modifOrder, searchLineById, searchPrice, getOrder } from '../../api/order/order.js';
import { searchInvoiceManageByFilters } from '../../api/meb-user/TaxsheetTitle.js';
import { getOrderReceptionsByOrderIdTable } from '../../api/order/receptionEntering.js';
import { isEmpty, getSelectObect } from '../../lib/util.js';
import { getStmHeavyRatio } from '../../api/system/StmHeavyRatio.js';
import { search } from '../../api/basedata/networkManagementApi.js';
import { searchALLPayWayConfig } from '../../api/system/PayWayConfig.js';

export default {
  data () {
    return {
      paymentTypes: [],
      noticeDelivery: false,
      token: this.$store.state.token,
      startNetworkManagements: [],
      endNetworkManagements: [],
      id: this.$route.params.id,
      isCargoShow: false,
      isPackTypeShow: false,
      isCargoShowText: '手输',
      isPackTypeShowText: '手输',
      radio: '',
      taxsheetTitles: [],
      taxsheetTitle: '',
      historyReceptionEnteringDialog: false,
      orderReceptions: [],
      memberUsers: [],
      extractTypes: [],
      sendTypes: [],
      orderCostDetailForm: [],
      shipmentAddresses: [],
      shipmentAddressesSelectModel: [], // 发货地址备用model
      sendAddressSelectModel: [], // 收货地址备用model
      shipmentAddressesSelectid: '', // 发货地址备用id
      sendAddressSelectId: '', // 收货地址备用id
      sendAddresses: [],
      invoiceAddressSelect: [],
      invoiceAddressSelectStreet: '',
      cargoNames: [],
      packTypes: [],
      invoiceTypes: [],
      receiptTypes: [],
      shippings: [],
      extractTimes: [{
        cnDictValname: '08:30-11:30',
        dictVal: '08:30-11:30'
      }, {
        cnDictValname: '13:30-18:00',
        dictVal: '13:30-18:00'
      }, {
        cnDictValname: '19:30-22:00',
        dictVal: '19:30-22:00'
      }],
      cnDictValname: '',
      send_contactPhone: '',
      send_telephone: '',
      send_street: '',
      shipment_contactPhone: '',
      shipment_telephone: '',
      shipment_street: '',
      cargoTypeName: '',
      shipmentsDateValuePOS: {
        discount: {},
        disabledDate (time) {
          return time.getTime() < Date.now() - 8.64e7;
        }
      },
      extractTimeValuePOS: {
        disabledDate (time) {
          return time.getTime() < Date.now() - 8.64e7;
        }
      },
      sendTimeValuePOS: {
        disabledDate (time) {
          return time.getTime() < Date.now() - 8.64e7;
        }
      },
      shipmentsDateValue: '',
      extractTimeValue: '',
      activeNames: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
      record: ['1'],
      orderCargoFormRules: {
        cargoId: [
          {required: true, trigger: 'change', validator: this.checkCargo}
        ],
        amount: [
          {required: true, message: '请输入货品件数'},
          {type: 'integer', message: '请输入正整数'}
        ],
        agingId: [
          {required: true, message: '请选择服务产品', trigger: 'blur'}
        ]
      },
      rules: {
        memberUserId: [
          {required: true, message: '请选择用户', trigger: 'blur'}
        ],
        shipmentsDate: [
          {type: 'date', required: true, message: '请输入发货日期', trigger: 'blur'}
        ],
        extractType: [
          {required: true, type: 'number', message: '请输入提货方式', trigger: 'change'}
        ],
        sendType: [
          {required: true, type: 'number', message: '请输入送货方式', trigger: 'change'}
        ],
        shipmentsContactName: [
          {required: true, message: '请输入发货人', trigger: 'blur'}
        ],
        shipmentAddress: [
          {required: true, message: '请输入发货人地址', trigger: 'blur'}
        ],
        sendContactName: [
          {required: true, message: '请输入收货人', trigger: 'blur'}
        ],
        sendAddress: [
          {required: true, message: '请输入收货人地址', trigger: 'blur'}
        ]
      },
      orderCargoForm: {
        cargoModel: '',
        cargoName: '',
        cargoId: '',
        cargoType: '',
        cargoTypeName: '',
        packType: '',
        packTypeName: '',
        weight: '',
        volume: '',
        amount: '',
        remark: ''
      },
      receiptTypeModel: '', // 回单
      invoiceTypeModel: '', // 发票
      addValues: [
        {
          dictValue: 101002001, // 保价声明
          value: '',
          valueMessage: '',
          remark: ''
        },
        {
          dictValue: 101002002, // 货代金额
          value: '',
          valueMessage: '',
          remark: ''
        },
        {
          dictValue: '', // 回单类型
          value: '',
          valueMessage: '',
          remark: ''
        },
        {
          dictValue: '', // 发票类型
          value: '',
          valueMessage: '',
          remark: '',
          taxsheetTitleId: '',
          taxsheetTitle: ''
        },
        {
          dictValue: '', // 等通知放货
          value: '',
          valueMessage: '',
          remark: ''
        }],
      orderForm: {
        valueMessage: '',
        orderReception: [], //
        orderReceptionBo: false, //
        orderNumber: '', // 订单编号
        createUser: '', // 录入人员
        createDate: '', // 录入时间
        orderSource: '', // 订单来源
        remark: '', // 订单备注
        mMebPersonal: {
          partnerName: ''
        },
        organizationModel: {
          name: ''
        },
        orderSourceModel: {
          cnDictValname: ''
        },
        orderStatusModel: {
          cnDictValname: ''
        },
        preferentialLine: '', // 优惠线路
        advanceOrder: '', // 提前下单
        memberUserId: '',
        memberUserName: '',
        memberUser: '',
        freightNumber: '', // 货运单号
        transportationNumber: '', // 运单号
        shipmentsDate: '', // 发货时间
        extractType: '', // calculatePrice
        extractDate: '',
        extractTime: '',
        sendType: '', // 送货类型
        orderPrice: '', // 订单总金额
        sendTime: '',
        shipmentsAddressId: '', // 发货地址
        shipmentAddressesSelect: [], // 发货地址数组
        shipmentsProvince: '', // 发货-省
        shipmentsProvinceId: '', // 发货-省id
        shipmentsCity: '', // 发货-市
        shipmentsCityId: '', // 发货-市id
        shipmentsCounty: '', // 发货-县
        shipmentsCountyId: '', // 发货-县id
        shipmentsTown: '', // 发货-乡/镇/街道
        shipmentsTownId: '', // 发货-乡/镇/街道id
        shipmentsContactName: '',
        shipmentsContactPhone: '',
        shipmentsTelephone: '',
        shipmentsAddress: '',
        shipmentsStreet: '',
        sendAddressSelect: [], // 收货地址数组
        sendAddressId: '', // 收货地址
        sendProvince: '', // 收货-省
        sendProvinceId: '', // 收货-省id
        sendCity: '', // 收货-市
        sendCityId: '', // 收货-市id
        sendCounty: '', // 收货-县
        sendCountyId: '', // 收货-县id
        sendTown: '', // 收货-乡/镇/街道
        sendTownId: '', // 收货-乡/镇/街道id
        sendContactName: '',
        sendContactPhone: '',
        sendTelephone: '',
        sendAddress: '',
        sendStreet: '',
        orderCargos: [], // 货物信息
        addValues: [], // 增值服务
        paymentType: '', // 付款方式
        orderStatus: '', // 订单状态
        agingModel: '', // 时效方式model
        agingId: '', // 时效方式
        agingName: '', // 时效方式名称
        orderCostDetails: [], // 订单费用明细
        startNetworkManagementId: '', // 自送
        endNetworkManagementId: '', // 自提
        noticeDeliveryStatus: 101022001 // 等通知放货状态-默认正常放货
      },
      oldOrderForm: {
        shipmentsAddressId: '', // 发货地址
        shipmentAddressesSelect: [], // 发货地址数组
        shipmentsProvince: '', // 发货-省
        shipmentsProvinceId: '', // 发货-省id
        shipmentsCity: '', // 发货-市
        shipmentsCityId: '', // 发货-市id
        shipmentsCounty: '', // 发货-县
        shipmentsCountyId: '', // 发货-县id
        shipmentsContactName: '',
        shipmentsTown: '', // 发货-乡/镇/街道
        shipmentsTownId: '', // 发货-乡/镇/街道id
        shipmentsContactPhone: '',
        shipmentsTelephone: '',
        shipmentsAddress: '',
        shipmentsStreet: '',
        sendAddressSelect: [], // 收货地址数组
        sendAddressId: '', // 收货地址
        sendProvince: '', // 收货-省
        sendProvinceId: '', // 收货-省id
        sendCity: '', // 收货-市
        sendCityId: '', // 收货-市id
        sendCounty: '', // 收货-县
        sendCountyId: '', // 收货-县id
        sendContactName: '',
        sendContactPhone: '',
        sendTown: '', // 收货-乡/镇/街道
        sendTownId: '', // 收货-乡/镇/街道id
        sendTelephone: '',
        sendAddress: '',
        sendStreet: ''
      },
      orderPrice: {
        grossfreight: '', // 总运费
        shortHaul: '', // 短途提货费
        trunkFreight: '', // 干线运费
        shortDeliveryCharge: '', // 短途送货费
        monthlyFee: '', // 月结费
        insured: '', // 保价
        collection: '', // 代收货款
        theReceipt: '', // 回单
        invoice: '', // 发票
        remark: '', // 备注
        costDetailTotal: ''// 费用明细的总和
      },
      orderPrices: [],
      sxType: '', // 时效方式
      inds: false, //
      hdds: false, //
      fbtitleds: false, //
      linePrice: '',
      initOrderCostDetailForm: [],
      initPage: true,
      discount: '',
      totalPrice: '',
      freightPrice: '',
      freightMsgPrice: '',
      backTaxsheetTitleId: '',
      fbdictValue: '',
      agingTypeId: '',
      orderRecord: [],
      // 订单状态对象
      orderStatus: {
        awaitPayAndAwaitAssign: true, // 待支付&待分派
        awaitPayAndAlreadyAssign: true, // 待支付 & 已分派
        alreadyPay: true, // 已支付
        alreadyPayCon: true, // 已支付& 合同运价
        agingDictEntityId: '', // 时效类型
        djagingDictEntityPayNoAss: '', // 定价快运的已支付待分派
        djagingDictEntityPay: '', // 定价快运的已支付已分派
        yetAss: false, // 已分派
        swartnotAss: false // 非定价快运的 待支付&待分派
      },
      isExecuteSetAddress: false, // 是否执行设置地址的方法
      isDSCode: false, // 之前是否 是定时快运
      isDefaultTitle: false,
      bjzd: 0,
      duthf: '', // 短途提货费
      bjyf: '', // 保价运费
      gxyf: '', // 干线运费
      dshkf: '', // 代收货款费
      dtshf: '', // 短途送货费
      yjf: '', // 月结费
      hdf: '', // 回单费
      xxf: '', // 信息费
      fpf: '', // 发票费
      mStmHeavyRatioInterval: '', // 获取重泡比区间
      isHeavyRatioInterval: false, // 是否重泡比区间
      iszp: false
    };
  },
  props: {
    title: {}
  },
  methods: {
    /**
       * 修改历史记录
       */
    getOrderReceptionsByOrderId () {
      getOrderReceptionsByOrderIdTable({'order_id': this.id, type: true}).then((res) => {
        this.orderRecord = res.data.detailModelList;
      });
    },
    checkCargo (rule, value, callback) {
      if (this.isCargoShow && isEmpty(this.orderCargoForm.cargoName)) {
        return callback(new Error('请输入货品名称'));
      }
      if (!this.isCargoShow && isEmpty(this.orderCargoForm.cargoId)) {
        return callback(new Error('请选择货品名称'));
      }
      callback();
    },
    elseCargoClick () {
      if (this.isCargoShow) {
        this.isCargoShowText = '手输';
        this.isCargoShow = false;
      } else {
        this.isCargoShowText = '选择';
        this.isCargoShow = true;
      }
    },
    elsePackTypeClick () {
      if (this.isPackTypeShow) {
        this.isPackTypeShowText = '手输';
        this.isPackTypeShow = false;
      } else {
        this.isPackTypeShowText = '选择';
        this.isPackTypeShow = true;
      }
    },
    addValueChange (val) {
      if (val === 'bj') {
        if ((this.addValues[0].value < 3000 || this.addValues[0].value > 1000000) && !isEmpty(this.addValues[0].value)) {
          return this.$message.error('保价金额范围在3000-1000000');
        }
      } else {
        if ((this.addValues[1].value < 1 || this.addValues[1].value > 50000) && !isEmpty(this.addValues[1].value)) {
          return this.$message.error('代收金额范围在1-50000');
        }
      }
      if (this.orderForm.agingDictEntityId === 112006003) {
        this.pricing();
      } else {
        this.calculatePrice();
      }
    },
    searchReservationRuleFreights (startAddressDicts, endAddressDicts) {
      searchReservationRuleFreights({
        start_address_dicts: startAddressDicts.join(','),
        end_address_dicts: endAddressDicts.join(',')
      }).then((res) => {
        res.data.detailModelList.push({
          days: 0,
          percentage: ''
        });
        for (let days in res.data.detailModelList) {
          let mr = res.data.detailModelList[days];
          let push = mr.appointDay + 1;
          var d = new Date(Date.now());
          d.setDate(d.getDate() + push - 1);
          var years = d.getFullYear();
          var months = d.getMonth();
          var day = d.getDate();
          this.shipmentsDateValuePOS.discount[new Date(years, months, day).getTime()] = '<label style="display: block;color: red;font-size: 9px;">' + mr.discountRate + '</label>';
        }
      });
    },
    searchReceiptTypeChange (val) {
      if (!isEmpty(val) && !isEmpty(val.dictVal)) {
        this.addValues[2].dictValue = val.dictVal;
        this.addValues[2].value = val.cnDictValname;
      }
      if (!isEmpty(val) && isEmpty(val.dictVal)) {
        if (val !== '电子回单' && val !== '原件回单') {
          this.addValues[2].dictValue = val;
          this.addValues[2].value = val;
        }
      }
      this.calculatePrice();
    },
    // 初始化发票
    setInvoiceType (val) {
      if (!isEmpty(val) && !isEmpty(val.dictVal)) {
        this.invoiceTypeModel = val.cnDictValname;
        this.addValues[3].dictValue = val.dictVal;
        this.addValues[3].value = val.cnDictValname;
      }
    },
    invoiceTypeChange (val) {
      let type = '';
      this.addValues[3].dictValue = '';
      if (val === 101002005) {
        // name = '个人普通发票';
        type = 102013001;
        this.addValues[3].dictValue = 101002005;
        this.addValues[3].value = '个人普通发票';
      }
      if (val === 101002006) {
        // name = '单位普通发票';
        type = 102013002;
        this.addValues[3].dictValue = 101002006;
        this.addValues[3].value = '单位普通发票';
      }
      if (val === 101002007) {
        // name = '增值税发票';
        type = 102013003;
        this.addValues[3].dictValue = 101002007;
        this.addValues[3].value = '增值税发票';
      }
      if (isEmpty(val)) {
        this.orderForm.valueMessage = '';
        this.taxsheetTitle = '';
      } else {
        this.searchTaxsheetTitle('EQ_taxsheetType=' + type + ';');
      }
      this.taxsheetTitles = [];
      this.taxsheetTitle = '';
      this.calculatePrice();
    },
    searchextractTypeChange (val) {
      if (val === 105002002) {
        this.orderForm.extractDate = null;
        this.orderForm.extractTime = null;
      }
      this.orderForm.startNetworkManagementId = '';
      this.calculatePrice();
    },
    sendTypeTypeChange (val) {
      if (val === 105001002) {
        this.orderForm.sendTime = null;
      }
      this.orderForm.endNetworkManagementId = '';
      this.calculatePrice();
    },
    getNetworkManagements (params) {
      search(params).then((res) => {
        this.startNetworkManagements = [];
        this.endNetworkManagements = [];
        if (res.data.successFlg && !isEmpty(res.data.detailModelList)) {
          this.startNetworkManagements = res.data.obj.starts;
          this.endNetworkManagements = res.data.obj.ends;
        }
      });
    },
    bfcalculatePrice (val) {
      if ((this.shippings.length > 1 && this.shippings[0].ageingType !== 112006004) && this.isDSCode === 112006003 && val.ageingType !== this.orderForm.agingDictEntityId) {
        // 标准快运和定时快运切换时清除结算方式---排除合同线路
        this.orderForm.paymentType = null;
      }
      if (!isEmpty(val)) {
        this.orderForm.agingDictEntityId = val.ageingType;
        if (val.ageingType === 112006003) {
          this.pricing();
        } else {
          this.calculatePrice();
        }
      }
      if (!isEmpty(val)) {
        this.isDSCode = val.ageingType;
      }
      this.getPaymentTypes(val);
    },
    changeVolumeAndWeight () {
      if (!isEmpty(this.orderCargoForm.weight) && !isEmpty(this.orderCargoForm.volume)) {
        let heavyRatioIntervalRatio = this.orderCargoForm.volume / this.orderCargoForm.weight;
        if (!isEmpty(this.mStmHeavyRatioInterval) && (this.mStmHeavyRatioInterval.minimum <= heavyRatioIntervalRatio && heavyRatioIntervalRatio <= this.mStmHeavyRatioInterval.maximum)) {
          this.iszp = true;
        } else {
          this.iszp = false;
        }
        if (!isEmpty(this.mStmHeavyRatioInterval) && this.mStmHeavyRatioInterval.minimum <= heavyRatioIntervalRatio && heavyRatioIntervalRatio <= this.mStmHeavyRatioInterval.maximum) {
          this.isHeavyRatioInterval = true;
          if (this.mStmHeavyRatioInterval.isPricingExpress === 111002001) {
            this.orderForm.agingModel = null;
            this.setShipings({ageingType: 112006003});
          }
        } else {
          this.isHeavyRatioInterval = false;
          this.sendAddressSelectChange();
        }
      }
      ;
      this.calculatePrice();
    },
    calculatePrice () {
      let start = this.orderForm.shipmentAddressesSelect;
      let end = this.orderForm.sendAddressSelect;
      this.getNetworkManagements({
        start_province_id: start[0],
        start_city_id: start[1],
        start_county_id: start[2],
        end_province_id: end[0],
        end_city_id: end[1],
        end_county_id: end[2]
      });
      if (!isEmpty(this.orderForm) && this.orderForm.agingDictEntityId === 112006003) {
        // 定价快运
        this.pricing();
        return;
      }
      if (isEmpty(this.orderCargoForm.weight) && isEmpty(this.orderCargoForm.volume)) {
        return this.$message.error('体积和重量必须填写一项');
      }
      this.$refs['orderCargoForm'].validate((orderCargoFormValid) => {
        if (orderCargoFormValid) {
          if (isEmpty(this.orderForm.paymentType)) {
            return this.$message.error('请选择付款方式');
          }
          if (isEmpty(this.orderForm.agingDictEntityId)) {
            return this.$message.error('请选择服务产品');
          }
          this.orderForm.agingId = this.orderForm.agingModel.id;
          this.orderForm.agingName = this.orderForm.agingModel.ageingTypeName;
          let insuredV = '';
          let collectionV = '';
          let insuredProportion = '';
          let collectionProportion = '';
          let theReceiptV = '';
          getFreightAddValue(this.token).then((res) => {
            let AddValueData = res.data;
            if (AddValueData.successFlg) {
              for (let avd in AddValueData.detailModelList) {
                let avdModel = AddValueData.detailModelList[avd];
                if (avdModel.dictValue === 101002001) { // 保价比例
                  if (this.orderForm.agingDictEntityId === 112006004 && !isEmpty(this.freightContract.supportRatio) && this.freightContract.supportRatio > 0) {
                    insuredProportion = this.freightContract.supportRatio;
                    insuredV = this.addValues[0].value * insuredProportion;
                  } else {
                    insuredV = this.addValues[0].value * avdModel.value;
                    insuredProportion = avdModel.value;
                  }
                } else if (avdModel.dictValue === 101002002) { // 代收货款比例
                  if (this.orderForm.agingDictEntityId === 112006004 && !isEmpty(this.freightContract.collectRatio) && this.freightContract.supportRatio > 0) {
                    collectionProportion = this.freightContract.collectRatio;
                    collectionV = this.addValues[1].value * collectionProportion;
                  } else {
                    collectionProportion = avdModel.value;
                    collectionV = this.addValues[1].value * collectionProportion;
                  }
                } else if (avdModel.dictValue === parseInt(this.addValues[2].dictValue)) { // 回单值
                  if (this.orderForm.agingDictEntityId === 112006004 && !isEmpty(this.freightContract.receipt)) {
                    theReceiptV = this.freightContract.receiptValue;
                  } else {
                    theReceiptV = avdModel.value;
                  }
                }
              }
              let sp = this.shippings;
              for (let i = 0; i < sp.length; i++) {
                if (sp[i].id === this.orderForm.agingId) {
                  this.sxType = sp[i].ageingType;
                }
              }
              this.sxType = isEmpty(this.sxType) ? this.orderForm.agingDictEntityId : this.sxType;
              // 用于参与计费的model
              let priceModel = {
                insuredProportion: insuredProportion, // 保价比例
                collectionProportion: collectionProportion, // 代收货款比例
                cargoType: this.orderCargoForm.cargoType, // 货物类型
                userId: this.orderForm.memberUserId, // 货物类型
                theReceiptProportion: theReceiptV, // 回单比例
                insuredValue: this.addValues[0].value, // 保价
                collectionValue: this.addValues[1].value, // 代收货款
                insured: insuredV, // 保价*比例
                collection: collectionV, // 代收货款*比例
                theReceipt: theReceiptV, // 回单*比例
                extractType: this.orderForm.extractType, // 提货方式
                sendType: this.orderForm.sendType, // 送货方式
                theReceiptType: isEmpty(this.receiptTypeModel) ? '' : this.addValues[2].dictValue, // 回单类型
                invoiceType: this.addValues[3].dictValue, // 发票类型
                typeOfShipping: this.sxType, // 运输方式
                weight: this.orderCargoForm.weight, // 重量
                volume: this.orderCargoForm.volume, // 体积
                startOrderAddressId: this.orderForm.shipmentsAddressId,
                startCountyId: this.orderForm.shipmentsCountyId,
                startCityId: this.orderForm.shipmentsCityId,
                startTownId: this.orderForm.shipmentAddressesSelect[3],
                endOrderAddressId: this.orderForm.sendAddressId,
                endCountyId: this.orderForm.sendCountyId,
                endCityId: this.orderForm.sendCityId,
                endTownId: this.orderForm.sendAddressSelect[3],
                isFrhtContract: this.lineType === 112006004 ? 111002001 : 111002002,
                baseFreightId: this.orderForm.agingId, // 基础运价ID
                percentage: this.discount, // 优惠比例
                payWay: this.orderForm.paymentType// 付款方式
              };
              searchPrice({
                json_model: JSON.stringify(priceModel)
              }).then((res) => {
                if (res.data.successFlg) {
                  if (this.lineType === 112006004) {
                    this.orderForm.agingModel.id = res.data.obj.ageingId;
                    this.orderForm.agingId = res.data.obj.ageingId;
                  }
                  this.orderPrice = res.data.obj;
                  this.orderPrices = this.orderForm.orderCostDetails = res.data.detailModelList;
                  this.orderPrices = this.orderForm.orderCostDetails = res.data.detailModelList;
                  this.orderForm.orderPrice = this.orderPrice.grossfreight;
                  let tp = 0;
                  for (let orderPrice in this.orderPrices) {
                    if (!isEmpty(this.addValues[0].value)) { // 保价比例
                      for (let op in this.orderPrices) {
                        if (this.orderPrices[op].costCode === 101005005 && this.orderPrices[op].costPrice < parseFloat(this.bjzd)) {
                          this.orderPrices[op].costPrice = parseFloat(this.bjzd);
                        }
                      }
                    }
                    if (!isEmpty(this.orderPrices[orderPrice].costPrice)) {
                      console.log(this.orderPrices[orderPrice].costName + '===' + this.orderPrices[orderPrice].costPrice);
                      tp += this.orderPrices[orderPrice].costPrice;
                    }
                    if (this.orderPrices[orderPrice].costCode === 101005002) {
                      this.linePrice = this.orderPrices[orderPrice].costPrice;
                    }
                  }
                  this.totalPrice = '订单金额：' + Math.round(tp * 100) / 100 + '元';
                  this.$message.success('费用计算成功');
                  this.orderForm.orderPrice = tp;
                  this.showOrderCostDetail(this.orderPrices);
                } else {
                  this.$message.error('订单价格计算异常');
                }
              });
            }
          });
        }
      });
    },
    searchTaxsheetTitleRm (val) {
      let filters = 'LIKE_taxsheetTitle=' + val + ';';
      if (!isEmpty(this.invoiceTypeModel)) {
        filters += 'EQ_taxsheetType=' + this.invoiceTypeModel + ';';
      }
      this.searchTaxsheetTitle(filters);
    },
    searchTaxsheetTitle (val) {
      let filters = '';
      if (isEmpty(val)) {
        filters = 'EQ_userId=' + this.orderForm.memberUserId;
      } else {
        filters = val + 'EQ_userId=' + this.orderForm.memberUserId;
      }
      searchInvoiceManageByFilters({
        filters: filters,
        sorts: '-createDate',
        size: '15',
        page: '1'
      }).then((res) => {
        this.isTaxsheetTitlesDefault = false;
        let models = res.data.detailModelList;
        this.taxsheetTitles = models;
        // 设置发票抬头
        let avm = this.orderForm.addValues.filter(av => {
          if ([101002005, 101002006, 101002007].contains(av.dictValue) && !isEmpty(av.taxsheetTitleId)) {
            return av;
          }
        })[0];
        for (let m in models) {
          if (!isEmpty(avm) && models[m].id === avm.taxsheetTitleId) {
            this.taxsheetTitle = avm.taxsheetTitleId;
          }
          if (models[m].isDefault === 111002001 && (!isEmpty(this.backTaxsheetTitleId) && this.addValues[3].dictValue === this.backTaxsheetTitleId.dictValue)) {
            if (models[m].taxsheetType === 102013001) {
              this.invoiceTypeModel = '个人普通发票';
            }
            if (models[m].taxsheetType === 102013002) {
              this.invoiceTypeModel = '单位普通发票';
            }
            if (models[m].taxsheetType === 102013003) {
              this.invoiceTypeModel = '增值税发票';
            }
            this.isTaxsheetTitlesDefault = true;
          }
        }
        if (isEmpty(this.taxsheetTitle) && !isEmpty(avm)) {
          this.taxsheetTitle = avm.taxsheetTitle;
        }
      });
    },
    searchTaxsheetTitleChange (val) {
      let model = getSelectObect(val, 'id', this.taxsheetTitles);
      this.addValues[3].taxsheetTitleId = val;
      if (!isEmpty(model)) {
        this.addValues[3].taxsheetTitle = model.taxsheetTitle;
        this.invoiceAddressSelect = [model.provinceId, model.cityId, model.countyId];
        this.invoiceAddressSelectStreet = model.street;
        this.orderForm.valueMessage = model.taxsheetTitle;
      }
    },
    createOrder (orderStatus, type) {
      if (isEmpty(this.orderForm.paymentType)) {
        return this.$message.error('请选择结算方式');
      }
      if (isEmpty(this.orderForm.shipmentAddressesSelect[2])) {
        return this.$message.error('始发地地址请至少选择到区县一级');
      }
      if (isEmpty(this.orderForm.sendAddressSelect[2])) {
        return this.$message.error('目的地地址请至少选择到区县一级');
      }
      if (this.isDefaultTitle && (isEmpty(this.addValues[3].dictValue) || isEmpty(this.taxsheetTitle))) {
        return this.$message.error('请选择发票类型和抬头');
      }
      if (isEmpty(this.orderForm.orderPrice) || this.orderForm.orderPrice <= 0) {
        return this.$message.error('订单金额异常！请尝试点击预估费用');
      }
      if (this.orderForm.agingDictEntityId === 112006003 || this.orderForm.agingModel.ageingType === 112006003) {
        if (isEmpty(this.freightPrice)) {
          return this.$message.error('请输入运费');
        }
      }
      if (isEmpty(this.orderCargoForm.weight) && isEmpty(this.orderCargoForm.volume)) {
        return this.$message.error('体积和重量必须填写一项');
      }
      for (let op in this.orderPrices) {
        if (this.orderPrices[op].costCode === 101005002) {
          if (isEmpty(this.orderPrices[op].costPrice)) {
            return this.$message.error('请输入运费');
          }
        }
      }
      this.orderForm.orderReception = this.orderCostDetailForm;
      if (!isEmpty(this.addValues[0].value) && (this.addValues[0].value < 3000 || this.addValues[0].value > 1000000)) {
        return this.$message.error('保价金额范围在3000-1000000');
      }
      if (!isEmpty(this.addValues[1].value) && (this.addValues[1].value < 1 || this.addValues[1].value > 50000)) {
        return this.$message.error('代收金额范围在1-50000');
      }
      if (!isEmpty(this.orderForm.shipmentsDate)) {
        this.orderForm.shipmentsDate = new Date(this.orderForm.shipmentsDate);
      }
      if (!isEmpty(this.orderForm.extractDate)) {
        this.orderForm.extractDate = new Date(this.orderForm.extractDate);
      }
      if (!isEmpty(this.orderForm.sendTime)) {
        this.orderForm.sendTime = new Date(this.orderForm.sendTime);
      }
      if (this.noticeDelivery) {
        this.addValues[4].dictValue = 101002009;
        this.addValues[4].value = '等通知放货';
        this.orderForm.noticeDeliveryStatus = 101022002;
      } else {
        this.addValues[4].dictValue = '';
        this.addValues[4].value = '';
        this.orderForm.noticeDeliveryStatus = 101022001;
      }
      // 表单验证
      this.$refs['orderForm'].validate((valid) => {
        if (valid) {
          this.$refs['orderCargoForm'].validate((orderCargoFormValid) => {
            if (isEmpty(this.orderForm.orderPrice)) {
              return this.$message.error('请先预估费用');
            }
            if (orderCargoFormValid) {
              if (!isEmpty(this.discount)) {
                this.orderForm.orderDiscount = this.discount;
              }
              if (!isEmpty(this.orderForm.agingModel)) {
                this.orderForm.agingId = this.orderForm.agingModel.id;
                this.orderForm.agingName = this.orderForm.agingModel.ageingTypeName;
              }
              if (this.orderForm.orderCostDetails.length <= 0) {
                this.calculatePrice();
              }
              if (this.orderForm.extractDate !== '' && this.orderForm.extractDate !== undefined && this.orderForm.extractDate !== null) {
                this.orderForm.extractDate = new Date(this.orderForm.extractDate).Format('yyyy-MM-dd');
              }
              if (this.orderForm.sendTime !== '' && this.orderForm.sendTime !== undefined && this.orderForm.sendTime !== null) {
                this.orderForm.sendTime = new Date(this.orderForm.sendTime).Format('yyyy-MM-dd');
              }
              if (this.isCargoShow) {
                this.orderCargoForm.cargoId = null;
                this.orderCargoForm.cargoType = null;
              }
              if (this.isPackTypeShow) {
                this.orderCargoForm.packType = null;
              }

              this.orderForm.orderCargos[0] = this.orderCargoForm;

              if (this.orderForm.invoiceAddressModel === 111003) {
                this.orderForm.invoiceAddressId = '';
              }
              // 移除空的
              let newAddValues = [];
              for (let addValue in this.addValues) {
                if (!isEmpty(this.addValues[addValue].value) && !isEmpty(this.addValues[addValue].dictValue)) {
                  newAddValues.push(this.addValues[addValue]);
                }
              }
              this.orderForm.shipmentsProvinceId = this.orderForm.shipmentAddressesSelect[0];
              this.orderForm.shipmentsCityId = this.orderForm.shipmentAddressesSelect[1];
              this.orderForm.shipmentsCountyId = this.orderForm.shipmentAddressesSelect[2];
              this.orderForm.shipmentsTownId = this.orderForm.shipmentAddressesSelect[3];
              this.orderForm.sendProvinceId = this.orderForm.sendAddressSelect[0];
              this.orderForm.sendCityId = this.orderForm.sendAddressSelect[1];
              this.orderForm.sendCountyId = this.orderForm.sendAddressSelect[2];
              this.orderForm.sendTownId = this.orderForm.sendAddressSelect[3];
              this.orderForm.orderCostDetails = this.orderPrices;
              this.orderForm.addValues = newAddValues;
              modifOrder(this.token, this.orderForm).then((res) => {
                if (res.data.successFlg) {
                  this.getOrderReceptionsByOrderId();
                  if (type === 'saveAndReset' && res.data.successFlg) {
                    this.resetOrderForm();
                  }
                  this.$message.success('保存成功');
                } else {
                  this.$message.error('保存失败');
                }
              });
            }
          });
        }
      });
    },
    searchMemberUsers (val) {
      let filters = isEmpty(val) ? '' : 'realName?' + val;
      getMemberUsers({
        token: this.token,
        filters: filters,
        sorts: '',
        size: '15',
        page: '1'
      }).then((res) => {
        this.memberUsers = res.data.detailModelList;
      });
    },
    searchextractTypes (dictCodeId) {
      getDictEntityByDictCode({token: this.token, dictCode: dictCodeId}).then((res) => {
        if (dictCodeId === 105002) {
          this.extractTypes = res.data.detailModelList;
        } else {
          this.sendTypes = res.data.detailModelList;
        }
      });
    },
    searchShipmentAddresses (addressTypeId) {
      getAddresses({
        token: this.token,
        filters: 'addressType=' + addressTypeId + ' g0;userId=' + this.orderForm.memberUserId + ' g1',
        sorts: '-createDate',
        size: '15',
        page: '1'
      }).then((res) => {
        if (addressTypeId === 109002002) {
          this.shipmentAddresses = res.data.detailModelList;
        } else {
          this.sendAddresses = res.data.detailModelList;
        }
      });
    },
    shipmentsContactNameChange (val) {
      this.isExecuteSetAddress = false;
      let shipmentAddresses = this.shipmentAddressesSelectModel = getSelectObect(val, 'id', this.shipmentAddresses);
      if (!isEmpty(shipmentAddresses)) {
        this.orderForm.shipmentsAddressId = shipmentAddresses.id;
        this.orderForm.shipmentsContactName = shipmentAddresses.contactName;
        this.orderForm.shipmentsContactPhone = shipmentAddresses.contactPhone;
        this.orderForm.shipmentsTelephone = shipmentAddresses.telephone;
        this.orderForm.shipmentsStreet = shipmentAddresses.street;
        this.orderForm.shipmentsProvinceId = shipmentAddresses.provinceId;
        this.orderForm.shipmentsCityId = shipmentAddresses.cityId;
        this.orderForm.shipmentsCountyId = shipmentAddresses.countyId;
        this.orderForm.shipmentAddressesSelect = [shipmentAddresses.provinceId, shipmentAddresses.cityId, shipmentAddresses.countyId, shipmentAddresses.townId];
      }
      this.orderForm.startNetworkManagementId = '';
      if (this.orderStatus.agingDictEntityId === 112006003 && this.orderStatus.alreadyPay) {
        return;
      }
      this.sendAddressSelectChange('shipmentAddress');
    },
    sendContactNameChange (val) {
      this.isExecuteSetAddress = false;
      let sendAddresses = this.sendAddressSelectModel = getSelectObect(val, 'id', this.sendAddresses);
      if (!isEmpty(sendAddresses)) {
        this.orderForm.sendAddressId = sendAddresses.id;
        this.orderForm.sendContactName = sendAddresses.contactName;
        this.orderForm.sendContactPhone = sendAddresses.contactPhone;
        this.orderForm.sendTelephone = sendAddresses.telephone;
        this.orderForm.sendStreet = sendAddresses.street;
        this.orderForm.sendProvinceId = sendAddresses.provinceId;
        this.orderForm.sendCityId = sendAddresses.cityId;
        this.orderForm.sendCountyId = sendAddresses.countyId;
        this.orderForm.sendAddressSelect = [sendAddresses.provinceId, sendAddresses.cityId, sendAddresses.countyId, sendAddresses.townId];
      }
      this.orderForm.endNetworkManagementId = '';
      if (this.orderStatus.agingDictEntityId === 112006003 && this.orderStatus.alreadyPay) {
        return;
      }
      this.sendAddressSelectChange('sendAddress');
    },
    searchItemNames () {
      getItemNames({
        token: this.token,
        filters: 'status=111002001',
        sorts: '',
        size: '40',
        page: '1'
      }).then((res) => {
        this.cargoNames = res.data.detailModelList;
      });
    },
    cargoNameChanges (val) {
      let cargoName = null;
      let cargoNames = this.cargoNames;
      for (let i = 0; i < cargoNames.length; i++) {
        if (cargoNames[i].id === val) {
          cargoName = cargoNames[i];
        }
      }
      if (!isEmpty(cargoName)) {
        this.orderCargoForm.cargoTypeName = cargoName.typeModel.cnDictValname;
        this.orderCargoForm.cargoType = cargoName.type;
        this.orderCargoForm.cargoId = cargoName.id;
        this.orderCargoForm.cargoName = cargoName.name;
      }
    },
    packTypeChanges (val) {
      let packTypeName = null;
      let packTypes = this.packTypes;
      for (let i = 0; i < packTypes.length; i++) {
        if (packTypes[i].dictVal === val) {
          packTypeName = packTypes[i];
        }
      }
      if (!isEmpty(packTypeName)) {
        this.orderCargoForm.packTypeName = packTypeName.cnDictValname;
      }
    },
    searchPackTypes () {
      getDictEntityByDictCode({token: this.token, dictCode: 109001}).then((res) => {
        this.packTypes = res.data.detailModelList;
      });
    },
    searchInvoiceTypes () {
      let filters = 'dictVal=101002005,101002006,101002007';
      getDictEntity({token: this.token, filters: filters}).then((res) => {
        this.invoiceTypes = res.data.detailModelList;
      });
    },
    searchReceiptTypes (val) {
      let filters = 'dictVal=101002003,101002004';
      getDictEntity({token: this.token, filters: filters}).then((res) => {
        this.receiptTypes = res.data.detailModelList;
      });
    },
    addressSelectChange (val) {
      this.isExecuteSetAddress = true;
      if (this.orderStatus.agingDictEntityId === 112006003 && this.orderStatus.alreadyPay) {
        return;
      }
      this.sendAddressSelectChange(val);
    },
    sendAddressSelectChange (val) {
      if (val === 'sendAddress') {
        this.orderForm.endNetworkManagementId = '';
      }
      if (val === 'shipmentAddress') {
        this.orderForm.startNetworkManagementId = '';
      }
      let shipmentAddressesModel = this.orderForm.shipmentAddressesSelect;
      let sendAddressModel = this.orderForm.sendAddressSelect;
      this.getNetworkManagements({
        start_province_id: shipmentAddressesModel[0],
        start_city_id: shipmentAddressesModel[1],
        start_county_id: shipmentAddressesModel[2],
        end_province_id: sendAddressModel[0],
        end_city_id: sendAddressModel[1],
        end_county_id: sendAddressModel[2]
      });

      if (this.orderForm.shipmentAddressesSelect.length < 3 || this.orderForm.sendAddressSelect.length < 3) {
        return;
      }
      this.searchReservationRuleFreights(shipmentAddressesModel, sendAddressModel);
      this.setAddress(val);
      searchLineById({
        user_id: this.orderForm.memberUserId,
        start_city_id: this.orderForm.shipmentAddressesSelect[1],
        start_county_id: this.orderForm.shipmentAddressesSelect[2],
        end_city_id: this.orderForm.sendAddressSelect[1],
        end_county_id: this.orderForm.sendAddressSelect[2]
      }).then((res) => {
        this.orderPrices = [];
        this.orderForm.orderPrice = 0;
        this.totalPrice = 0;
        this.showOrderCostDetail();
        this.shippings = [];
        if (res.data.successFlg) {
          this.shippings = [];
          this.lineType = 112006003;
          this.inds = false;
          this.hdds = false;
          /**
             * 合同快运
             */
          if (!isEmpty(res.data.obj)) {
            this.fbtitleds = true;
            this.inds = true;
            if (!isEmpty(res.data.obj.receipt)) {
              this.hdds = true;
              this.addValues[2].dictValue = res.data.obj.receipt.toString();
              this.receiptType = res.data.obj.receipt.toString();
            }
            this.orderForm.valueMessage = res.data.obj.taxsheetTitleName;

            this.freightContract = res.data.obj;
            this.lineType = 112006004;
            this.shippings.push({
              ageingTypeName: '合同运价',
              ageingType: 112006004,
              paymentType: res.data.obj.paymentType,
              paymentTypeName: res.data.obj.paymentTypeName
            });
            this.orderForm.agingModel = this.shippings[0];
            this.orderForm.paymentType = res.data.obj.paymentType;
          } else {
            // 非合同
            this.inds = false;
            this.fbtitleds = false;
            this.shippings = res.data.detailModelList;
            this.shippings.push({ageingTypeName: '定价快运', ageingType: 112006003, agingTypeId: 112006003});
          }
          for (let shipping in this.shippings) {
            if (this.orderForm.agingDictEntityId === this.shippings[shipping].ageingType) {
              if (res.data.detailModelList.length > 0) {
                this.agingTypeId = res.data.detailModelList[0].ageingType;
              }
              this.orderForm.agingModel = this.shippings[shipping];
              break;
            }
          }
          if (this.orderForm.agingDictEntityId === 112006003) {
            for (let ocd in this.orderForm.orderCostDetails) {
              if (this.orderForm.orderCostDetails[ocd].costCode === 101005002) {
                this.freightPrice = this.orderForm.orderCostDetails[ocd].costPrice;
              }
              if (this.orderForm.orderCostDetails[ocd].costCode === 101005014) {
                this.freightMsgPrice = this.orderForm.orderCostDetails[ocd].costPrice;
                continue;
              }
            }
          }
          let heavyRatioIntervalRatio = this.orderCargoForm.volume / this.orderCargoForm.weight;
          if (!isEmpty(this.mStmHeavyRatioInterval) && (this.mStmHeavyRatioInterval.minimum <= heavyRatioIntervalRatio && heavyRatioIntervalRatio <= this.mStmHeavyRatioInterval.maximum) && this.mStmHeavyRatioInterval.isPricingExpress === 111002001) {
            this.setShipings({ageingType: 112006003});
          }
        } else {
          // if (this.mStmHeavyRatioInterval.isPricingExpress === 111002001) {
          this.setShipings({ageingType: 112006003});
          // }
          if (this.orderForm.agingDictEntityId === 112006003) {
            for (let ocd in this.orderForm.orderCostDetails) {
              if (this.orderForm.orderCostDetails[ocd].costCode === 101005002) {
                this.freightPrice = this.orderForm.orderCostDetails[ocd].costPrice;
              }
              if (this.orderForm.orderCostDetails[ocd].costCode === 101005014) {
                this.freightMsgPrice = this.orderForm.orderCostDetails[ocd].costPrice;
                continue;
              }
            }
          }
          this.orderForm.agingModel = this.shippings[0];
        }

        let heavyRatioIntervalRatio = this.orderCargoForm.volume / this.orderCargoForm.weight;
        if (this.mStmHeavyRatioInterval.isPricingExpress === 111002001 && (this.mStmHeavyRatioInterval.minimum <= heavyRatioIntervalRatio && heavyRatioIntervalRatio <= this.mStmHeavyRatioInterval.maximum)) {
          for (let c = 0; c < this.shippings.length; c++) {
            if (this.shippings[c].ageingType !== 112006003) {
              this.shippings.splice(c, 1);
            }
          }
        }
      });
    },
    setAddress (val) {
      if (this.isExecuteSetAddress) {
        let thisSendAddress = this.orderForm.sendAddressSelect;
        let thisShipmentAddress = this.orderForm.shipmentAddressesSelect;
        let oof = this.oldOrderForm;
        this.orderForm.sendProvinceId = thisSendAddress[0];
        this.orderForm.sendCityId = thisSendAddress[1];
        this.orderForm.sendCountyId = thisSendAddress[2];
        this.orderForm.shipmentsProvinceId = thisShipmentAddress[0];
        this.orderForm.shipmentsCityId = thisShipmentAddress[1];
        this.orderForm.shipmentsCountyId = thisShipmentAddress[2];
        if (val === 'sendAddress' && (thisSendAddress[0] !== oof.sendProvinceId || thisSendAddress[1] !== oof.sendCityId || thisSendAddress[2] !== oof.sendCountyId)) {
          this.orderForm.sendAddressId = null;
        } else {
          this.orderForm.sendAddressId = oof.sendAddressId;
        }
        if (val === 'shipmentAddress' && (thisShipmentAddress[0] !== oof.shipmentsProvinceId || thisShipmentAddress[1] !== oof.shipmentsCityId || thisShipmentAddress[2] !== oof.shipmentsCountyId)) {
          this.orderForm.shipmentsAddressId = null;
        } else {
          this.orderForm.shipmentsAddressId = oof.shipmentsAddressId;
        }
      }
    },
    resetOrderForm () {
      location.reload();
    },
    getOrder (val) {
      getOrder(this.token, val).then((res) => {
        if (res.data.successFlg) {
          let snetId = res.data.obj.startNetworkManagementId;
          let enetId = res.data.obj.endNetworkManagementId;
          if (!isEmpty(res.data.obj.weight) && !isEmpty(res.data.obj.volume)) {
            let heavyRatioIntervalRatio = res.data.obj.volume / res.data.obj.weight;
            if (!isEmpty(this.mStmHeavyRatioInterval) && this.mStmHeavyRatioInterval.minimum <= heavyRatioIntervalRatio && heavyRatioIntervalRatio <= this.mStmHeavyRatioInterval.maximum) {
              this.isHeavyRatioInterval = true;
            } else {
              this.isHeavyRatioInterval = false;
            }
          }

          this.oldOrderForm = Object.assign({
            shipmentsAddressId: '', // 发货地址
            shipmentAddressesSelect: [], // 发货地址数组
            shipmentsProvince: '', // 发货-省
            shipmentsProvinceId: '', // 发货-省id
            shipmentsCity: '', // 发货-市
            shipmentsCityId: '', // 发货-市id
            shipmentsCounty: '', // 发货-县
            shipmentsCountyId: '', // 发货-县id
            shipmentsContactName: '',
            shipmentsTown: '', // 发货-乡/镇/街道
            shipmentsTownId: '', // 发货-乡/镇/街道id
            shipmentsContactPhone: '',
            shipmentsTelephone: '',
            shipmentsAddress: '',
            shipmentsStreet: '',
            sendAddressSelect: [], // 收货地址数组
            sendAddressId: '', // 收货地址
            sendProvince: '', // 收货-省
            sendProvinceId: '', // 收货-省id
            sendCity: '', // 收货-市
            sendCityId: '', // 收货-市id
            sendCounty: '', // 收货-县
            sendCountyId: '', // 收货-县id
            sendContactName: '',
            sendTown: '', // 收货-乡/镇/街道
            sendTownId: '', // 收货-乡/镇/街道id
            sendContactPhone: '',
            sendTelephone: '',
            sendAddress: '',
            sendStreet: ''
          }, res.data.obj);
          this.orderForm = res.data.obj;
          this.discount = this.orderForm.orderDiscount;
          if (this.orderForm && (this.orderForm.noticeDeliveryStatus === 101022002 || this.orderForm.noticeDeliveryStatus === 101022003)) {
            this.noticeDelivery = true;
          }
          this.orderForm.shipmentAddressesSelect = [this.orderForm.shipmentsProvinceId, this.orderForm.shipmentsCityId, this.orderForm.shipmentsCountyId, this.orderForm.shipmentsTownId];
          this.orderForm.sendAddressSelect = [this.orderForm.sendProvinceId, this.orderForm.sendCityId, this.orderForm.sendCountyId, this.orderForm.sendTownId];
          // 断言当前订单状态
          this.assertOrderStatus();
          if (isEmpty(this.orderForm.orderCargos[0].cargoId)) {
            this.isCargoShow = true;
          }
          if (isEmpty(this.orderForm.orderCargos[0].packType)) {
            this.isPackTypeShow = true;
          }
          this.searchTaxsheetTitle('EQ_taxsheetType=102013001;');
          this.orderPrice.preferentialLine = res.data.obj.preferentialLine;
          this.orderForm.orderCostDetails = this.initOrderCostDetailForm = res.data.obj.orderCostDetails;
          /**
             * 是否存在信息服务费
             **/
          let ocdBo = true;
          for (let os in this.orderForm.orderCostDetails) {
            if (this.orderForm.orderCostDetails[os].costCode === 101005014) {
              ocdBo = false;
            }
            this.orderForm.orderCostDetails[os].thisCostPrice = this.orderForm.orderCostDetails[os].costPrice;
          }
          if (ocdBo) {
            this.orderForm.orderCostDetails.push({
              costCode: 101005014,
              costPrice: '',
              costType: '运费',
              costName: '信息服务费'
            });
          }
          this.orderCargoForm = res.data.obj.orderCargos[0];
          if (res.data.obj.invoiceAddressId === res.data.obj.shipmentsAddressId) {
            this.orderForm.invoiceAddressModel = 111001;
          } else if (res.data.obj.invoiceAddressId === res.data.obj.sendAddressId) {
            this.orderForm.invoiceAddressModel = 111002;
          } else if (isEmpty(res.data.obj.invoiceAddressId)) {
            this.orderForm.invoiceAddressModel = 111003;
          }
          for (let selectAddValue in res.data.obj.addValues) {
            for (let addValue in this.addValues) {
              if (res.data.obj.addValues[selectAddValue].dictValue === parseInt(this.addValues[addValue].dictValue)) {
                this.addValues[addValue] = res.data.obj.addValues[selectAddValue];
              }
            }
          }
          this.agingTypeId = res.data.obj.agingDictEntityId;
          this.sendAddressSelectChange();
          // 回单
          for (let receiptType in this.receiptTypes) {
            for (let addValue in res.data.obj.addValues) {
              if (isEmpty(res.data.obj.addValues[addValue])) {
                continue;
              }
              if (res.data.obj.addValues[addValue].dictValue === parseInt(this.receiptTypes[receiptType].dictVal)) {
                this.receiptTypeModel = this.receiptTypes[receiptType].cnDictValname;
                this.searchReceiptTypeChange(this.receiptTypes[receiptType]);
              }
            }
          }
          // 备份发票抬头
          let avs = res.data.obj.addValues;
          for (let av in avs) {
            if (!isEmpty(avs[av].taxsheetTitleId)) {
              this.backTaxsheetTitleId = avs[av];
              break;
            }
          }
          // 发票
          for (let invoiceType in this.invoiceTypes) {
            for (let av in avs) {
              if (isEmpty(avs[av])) {
                continue;
              }
              if (avs[av].dictValue === parseInt(this.invoiceTypes[invoiceType].dictVal)) {
                this.addValues[3].dictValue = avs[av].dictValue;
                this.fbdictValue = avs[av].dictValue;
                this.invoiceTypeModel = this.invoiceTypes[invoiceType].cnDictValname;
                this.invoiceTypes[invoiceType].valueMessage = avs[av].valueMessage;
                this.setInvoiceType(this.invoiceTypes[invoiceType]);
              }
            }
          }
          this.invoiceAddressSelect = [res.data.obj.invoiceAddressProvinceId, res.data.obj.invoiceAddressCityId, res.data.obj.invoiceAddressCountyId];
          this.orderForm.invoiceAddressSelectStreet = res.data.obj.invoiceAddressStreet;
          // 费用
          this.orderPrice.grossfreight = res.data.obj.orderPrice;
          this.orderPrice.costDetailTotal = res.data.obj.orderPrice;
          this.orderPrices = res.data.obj.orderCostDetails;
          for (let orderPrice in this.orderPrices) {
            if (this.orderPrices[orderPrice].costCode === 101005002) {
              this.linePrice = this.orderPrices[orderPrice].costPrice;
            }
          }
          this.orderCargoForm.cargoId = res.data.obj.orderCargos[0].cargoId;
          this.getPaymentTypes({ageingType: res.data.obj.agingDictEntityId, payWays: res.data.obj.payWays});
          /**
             *  由于业务在改变收发货地址和提送货方式时要改变网点信息，
             *  且在页面初始化表单时会触发收发货地址和提送货方式
             *  互相冲突，所以在初始化页面时将网点信息的赋值滞后
             */
          setTimeout(() => {
            this.setNetWork(snetId, enetId);
          }, 1500);
        }
      });
    },
    setNetWork (snetId, enetId) {
      this.orderForm.startNetworkManagementId = snetId;
      this.orderForm.endNetworkManagementId = enetId;
    },
    setShipings (o) {
      if (o.ageingType === 112006003) {
        this.shippings = [];
        this.shippings.push({ageingTypeName: '定价快运', ageingType: 112006003, agingTypeId: 112006003});
      }
    },
    pricing () {
      this.orderPrices = [];
      if (!isEmpty(this.addValues[0].value)) { // 保价比例
        let amodel = this.figure(this.addValues[0].dictValue);
        let bj = this.addValues[0].value * amodel.value;
        if (bj < parseFloat(this.bjzd)) {
          bj = parseFloat(this.bjzd);
        }
        let bbjv = true;
        for (let po in this.orderPrices) {
          if (this.orderPrices.costCode === 101005005) {
            bbjv = false;
            this.orderPrices[po].costPrice = bj;
          }
        }
        if (bbjv) {
          this.orderPrices.push({
            amount: this.addValues[0].value,
            costCode: 101005005,
            costName: '保价',
            calculateUnit: '比例',
            calculateUnivalence: amodel.value,
            costPrice: bj
          });
        }
      }
      if (!isEmpty(this.addValues[1].value)) { // 代收货款比例
        this.orderPrices.push({
          amount: this.addValues[1].value,
          calculateUnivalence: this.figure(this.addValues[1].dictValue).value,
          costCode: 101005006,
          costName: '代收货款',
          calculateUnit: '比例',
          costPrice: this.addValues[1].value * this.figure(this.addValues[1].dictValue).value
        });
      }
      if (!isEmpty(this.addValues[2].value)) { // 回单比例
        let hdm = 0;
        if (this.addValues[2].dictValue === 101002003) {
          hdm = 101005007;
        } else {
          hdm = 101005008;
        }
        this.orderPrices.push({
          amount: 1,
          costCode: hdm,
          costName: '回单',
          calculateUnit: '比例',
          calculateUnivalence: this.figure(this.addValues[2].dictValue).value,
          costPrice: this.figure(this.addValues[2].dictValue).value
        });
      }
      if (!isEmpty(this.freightPrice)) {
        this.orderPrices.push({
          amount: 1,
          costCode: 101005002,
          costName: '干线运费',
          calculateUnit: '比例',
          calculateUnivalence: this.freightPrice,
          costPrice: this.freightPrice
        });
        this.linePrice = this.freightPrice;
      }
      if (!isEmpty(this.freightMsgPrice)) {
        this.orderPrices.push({
          amount: 1,
          costCode: 101005014,
          costName: '信息服务费',
          calculateUnit: '比例',
          calculateUnivalence: this.freightMsgPrice,
          costPrice: this.freightMsgPrice
        });
      }
      if (this.orderForm.agingDictEntityId === 112006003) {
      }
      if (!isEmpty(this.addValues[3].value) && this.orderForm.agingDictEntityId !== 112006003) { // 发票比例
        let sum = 0;
        for (let op in this.orderPrices) {
          if (!isEmpty(this.orderPrices[op].costPrice)) {
            sum += this.orderPrices[op].costPrice;
          }
        }
        this.orderPrices.push({
          amount: 1,
          calculateUnit: '比例',
          calculateUnivalence: this.figure(this.addValues[3].dictValue).value,
          costCode: this.addValues[3].dictValue,
          costName: '发票',
          costPrice: sum * this.figure(this.addValues[3].dictValue).value
        });
      }
      let totalPrice = 0;
      for (let orderPrice in this.orderPrices) {
        if (!isEmpty(this.orderPrices[orderPrice].costPrice)) {
          totalPrice += parseFloat(this.orderPrices[orderPrice].costPrice);
        }
      }
      /**
         * 设置总金额&费用明细
         * @type {number}
         */
      this.orderForm.orderPrice = Math.round(totalPrice * 100) / 100;
      this.totalPrice = '订单金额：' + this.orderForm.orderPrice + '元';
      this.showOrderCostDetail();
    },
    figure (dictValue) {
      let data = {};
      for (let avd in this.addValueData) {
        if (this.addValueData[avd].dictValue === parseInt(dictValue)) {
          data = this.addValueData[avd];
          break;
        }
      }
      return data;
    },
    getStmParamByType () {
      getStmParamByType({
        stmParamType: 'INSURED_MINIMUM_INSURED'
      }).then((res) => {
        this.bjzd = res.data.obj.stmParamVal;
      });
    },
    showOrderCostDetail () {
      this.duthf = 0;
      this.bjyf = 0;
      this.gxyf = 0;
      this.dshkf = 0;
      this.dtshf = 0;
      this.yjf = 0;
      this.hdf = 0;
      this.xxf = 0;
      this.fpf = 0;
      let heavyRatioIntervalRatio = this.orderCargoForm.volume / this.orderCargoForm.weight;
      if (!isEmpty(this.mStmHeavyRatioInterval) && (this.mStmHeavyRatioInterval.minimum <= heavyRatioIntervalRatio && heavyRatioIntervalRatio <= this.mStmHeavyRatioInterval.maximum) && this.mStmHeavyRatioInterval.isPricingExpress === 111002002) {
      }
      let msg = '';
      let gxf = 0;
      for (let odp in this.orderPrices) {
        let os = this.orderPrices[odp];
        let pe = Math.round(os.costPrice * 100) / 100;
        if (os.costCode === 101005001) {
          this.duthf = pe; // 短途提货费
        }
        if (os.costCode === 101005005) {
          this.bjyf = pe; // 保价运费
        }
        if (os.costCode === 101005002) {
          if (this.orderForm.agingDictEntityId !== 112006003) {
            gxf = pe;
            pe = pe + '(原价 ¥ ' + Math.round((os.costPrice + this.orderPrice.preferentialLine + this.orderPrice.advanceOrder) * 100) / 100 + '提前下单优惠' + this.orderPrice.advanceOrder + '元，线路优惠' + this.orderPrice.preferentialLine + '元)';
            msg = '  (原价 ¥ ' + Math.round((os.costPrice + this.orderPrice.preferentialLine + this.orderPrice.advanceOrder) * 100) / 100 + '提前下单优惠' + this.orderPrice.advanceOrder + '元，线路优惠' + this.orderPrice.preferentialLine + '元)';
          }
          this.gxyf = pe; // 干线运费
        }
        if (os.costCode === 101005006) {
          this.dshkf = pe; // 代收货款费
        }
        if (os.costCode === 101005003) {
          this.dtshf = pe; // 短途送货费
        }
        if (os.costCode === 101005004) {
          this.yjf = pe; // 月结费
          // this.gxyf = pe + msg;
          this.gxyf = (gxf + pe) + msg;
        }
        if (os.costCode === 101005007 || os.costCode === 101005008) {
          this.hdf = pe; // 回单费
        }
        if (os.costCode === 101005014) {
          this.xxf = pe; // 信息费
        }
        if (os.costCode === 101005009 || os.costCode === 101005010 || os.costCode === 101005011) {
          this.fpf = pe; // 发票费
        }
      }
    },
    setStmHeavyRatio () {
      let data = this.mStmHeavyRatioInterval;
      if (!isEmpty(data) && data.isPricingExpress === 111002002) {
        for (let odp in this.orderPrices) {
          // 短途提货费
          if (this.orderPrices[odp].costCode === 101005001 && data.isPickUpCharge === 111002001) {
            this.orderPrices[odp].costPrice = this.orderPrices[odp].costPrice + this.orderPrices[odp].costPrice * data.priceIncreaseRatio;
          }
          // 短途送货费
          if (this.orderPrices[odp].costCode === 101005003 && data.isDeliveryCharges === 111002001) {
            this.orderPrices[odp].costPrice = this.orderPrices[odp].costPrice + this.orderPrices[odp].costPrice * data.priceIncreaseRatio;
          }
          // 干线运费
          if (this.orderPrices[odp].costCode === 101005002 && data.isTrunkFreight === 111002001) {
            this.orderPrices[odp].costPrice = parseFloat(this.orderPrices[odp].costPrice) + parseFloat(this.orderPrices[odp].costPrice) * data.priceIncreaseRatio;
          }
        }
      }
    },
    backClick () {
      this.$router.push('/order/manage');
    },
    addvalues () {
      getFreightAddValue(this.token).then((res) => {
        this.addValueData = res.data.detailModelList;
      });
    },
    assertOrderStatus () {
      this.orderStatus.awaitPayAndAwaitAssign = false; // 待支付&待分派
      this.orderStatus.awaitPayAndAlreadyAssign = false; // 待支付 & 已分派
      this.orderStatus.swartnotAss = false; // 非定价快运的 待支付&待分派
      this.orderStatus.alreadyPay = false; // 已支付 & 待分派
      this.orderStatus.alreadyPayCon = false; // 已支付& 合同运价
      let data = this.orderForm;
      this.orderStatus.agingDictEntityId = data.agingDictEntityId;
      if (data.payStatus === 101003001 && isEmpty(data.assignOrganizationId)) {
        this.orderStatus.awaitPayAndAwaitAssign = true;
      }
      if (data.payStatus === 101003001 && !isEmpty(data.assignOrganizationId)) {
        this.orderStatus.awaitPayAndAlreadyAssign = true;
      }
      if (data.payStatus === 101003002) {
        this.orderStatus.alreadyPay = true;
      }
      // 非定价快运的 待支付&待分派
      if (data.agingDictEntityId !== 112006003 && data.payStatus === 101003001 && isEmpty(data.assignOrganizationId)) {
        this.orderStatus.swartnotAss = true;
      }
      // 定价快运 -已支付、待分派
      this.orderStatus.djagingDictEntityPayNoAss = false;
      if (data.payStatus === 101003002 && data.agingDictEntityId === 112006003 && isEmpty(data.assignOrganizationId)) {
        this.orderStatus.djagingDictEntityPayNoAss = false;
      }
      // 定价快运 -已分派
      if (data.agingDictEntityId === 112006003 && !isEmpty(data.assignOrganizationId)) {
        this.orderStatus.djagingDictEntityPayNoAss = true;
      }
      // 已分派
      if (!isEmpty(data.assignOrganizationId)) {
        this.orderStatus.yetAss = true;
      }
      if (data.payStatus === 101003002 && data.agingDictEntityId === 112006004) {
        this.orderStatus.alreadyPayCon = true;
        this.isCargoShow = false;
      }
    },
    getWhetherCompulsoryTaxsheet () {
      getStmParamByType({
        stmParamType: 'WHETHER_COMPULSORY_TAXSHEET'
      }).then((res) => {
        if (!isEmpty(res.data.obj) && parseInt(res.data.obj.stmParamVal) === 111002001) {
          this.isDefaultTitle = true;
        } else {
          this.isDefaultTitle = false;
        }
      });
    },
    /**
       * 获取重泡比区间
       */
    searchStmHeavyRatio () {
      getStmHeavyRatio().then((res) => {
        if (res.data.successFlg) {
          this.mStmHeavyRatioInterval = res.data.obj;
        }
      });
    },
    /**
       * 获取付款方式
       */
    getPaymentTypes (val) {
      if (isEmpty(val)) {
        return;
      }
      let filters = '';
      if (val.ageingType === 112006003) {
        filters = 'EQ_isEnable=true;EQ_isShow=true;';
      } else if (val.ageingType === 112006004) {
        this.paymentTypes = [{payWay: val.paymentType, payWayName: val.paymentTypeName}];
        return;
      } else {
        filters = 'IN_payWay=' + val.payWays.join(',');
      }
      this.paymentTypesFun(filters, data => {
        this.paymentTypes = data;
      });
    },
    paymentTypesFun (filters, fun) {
      searchALLPayWayConfig({
        filters: filters,
        sorts: ''
      }).then((res) => {
        if (res.data.successFlg) {
          return fun(res.data.detailModelList);
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    }
  },
  mounted () {
    this.searchStmHeavyRatio();
    this.searchReceiptTypes();
    this.searchInvoiceTypes();
    this.getWhetherCompulsoryTaxsheet();
    this.getOrder(this.id);
    this.getStmParamByType();
    this.addvalues();
    this.searchPackTypes();
    this.searchMemberUsers();
    this.searchItemNames();
    this.searchextractTypes(105001);
    this.searchextractTypes(105002);
    this.getOrderReceptionsByOrderId();
  },
  computed: {
    discountText: function () {
      let self = this;
      if (this.orderForm.shipmentsDate) {
        self.discount = this.shipmentsDateValuePOS.discount[new Date(this.orderForm.shipmentsDate).getTime()];
        if (isEmpty(this.discount)) {
          self.discount = '';
          return '';
        }
        let doms = this.discount.split('0.');
        if (doms.length === 1) {
          self.discount = '';
          return '';
        }
        self.discount = '0.' + doms[1].replace('</label>', '');
        return this.shipmentsDateValuePOS.discount[new Date(this.orderForm.shipmentsDate).getTime()];
      } else {
        return '';
      }
    }
  }
};
</script>
